Add support for file search - #321
Open
loookashow wants to merge 1 commit into
Open
Conversation
Expose the REST API v0.7 POST /files/search/ endpoint in the SDK. - Uploadcare.search_files(), returning one typed page, and Uploadcare.iterate_search_files(), which walks pages - FilesAPI.search() - Typed requests: FileSearchRequest with query, phrase, exact, datetime_uploaded, size, is_image and tags conditions plus the fuzziness and sort modifiers, built from SearchPhrase, SearchExact, DatetimeRange, SizeRange, TagsFilter and SearchSort. A plain dict in the same shape works too - FileSearchResponse with next, previous, total, per_page and results, each result a FileSearchInfo carrying a SearchHighlight - ucare search_files command Requests are validated locally against the documented API constraints before any request is made, so a malformed search fails fast with a clear message. Paging never requests the response's next URL: it is an absolute, server-supplied URL, and the REST client attaches credentials to whatever URL it is given. next is used only as a has-more signal and the offset is computed locally, clamped so no request exceeds the 1000-result window. total is not used as a stop condition because the API documents it as approximate for large result sets. iterate_search_files() warns when asked to page through a filter-only request without sort, whose result order the API leaves undefined. Search indexing is asynchronous (~10s), which the integration tests poll for and the docs note. highlight for a filter-only match arrives as an empty object rather than being absent as the reference states. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Contributor
Author
|
@dmitry-mukhin please review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Part 2 of 2, splitting #319 per @dmitry-mukhin's request. This is the file search half, stacked on top of the file tags PR (base branch
feat/file-tags) — search'sTagsFilterreusesvalidate_tagsfrom the tags module, so it depends on that PR. Review/merge the tags PR first; GitHub will retarget this one tomainautomatically.Exposes file search —
POST /files/search/.What's included
Uploadcare.search_files(), returning one typed page, andUploadcare.iterate_search_files(), which walks pages (limit= total to yield,request_limit= page size, as elsewhere in the SDK).FilesAPI.search().FileSearchRequest(query,phrase,exact,datetime_uploaded,size,is_image,tags+fuzziness/sort), also accepting a plain dict. All documented API constraints are validated locally before a request is made.FileSearchResponse(next,previous,total,per_page,results), each result aFileSearchInfowith aSearchHighlight.ucare search_filescommand.Notable decisions
nextURL — the REST client attaches credentials to any URL it is given, sonextis used only as a has-more signal and the offset is computed locally, clamped to the 1000-result window.totalis not used as a stop condition, since the API documents it as approximate for large result sets.iterate_search_files()warns when asked to page through a filter-only request withoutsort, whose result order the API leaves undefined.Testing
unittest.mockfor request shape and hand-authored cassettes for response parsing.tests/integration/test_file_search.py) cover conditions, modifiers, highlight, appdata and pagination against the live API. Search indexing is asynchronous (~10s), which the tests poll for and the docs now note.highlightfor a filter-only match arrives as an empty object rather than being absent as the reference states.make lintis clean; the full functional + Django suite passes (466 tests); the search integration suite passes against a live project.🤖 Generated with Claude Code